﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System.ComponentModel;
using System.Web.UI;

namespace Mobile.WebControls
{
    [ToolboxData("<{0}:Image runat=server></{0}:Image>")]
    public class Image : ThemedControl
    {
        #region Properties
        [Category("HTML Tag")]
        public string Source { get; set; }
        [Category("HTML Tag")]
        public string Alt { get; set; }
        #endregion

        #region Render Methods
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
        }

        public override void RenderEndTag(HtmlTextWriter writer)
        {
            writer.RenderEndTag(); 
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, Source);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, Alt);
        }
        #endregion

    }
}
